Passed
Branch master (9a7ed1)
by Rafael S.
01:20
created

40-bit.js ➔ describe(ꞌ40-bit to bytesꞌ)   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 26
rs 8.8571
1
2
var assert = require('assert');
3
4
describe('40-bit to bytes', function() {
5
    
6
    let byteData = require('../../index.js');
7
8
    // 40 bit
9
    it('should turn 5 bytes (hex) to 1 signed 40-bit int  (max range)', function() {
10
        assert.deepEqual(byteData.toBytes([549755813887], 40, {"base": 16}),
11
            ["ff","ff","ff","ff","7f"]);
12
    });
13
    it('should turn 5 bytes (hex) to 1 signed 40-bit int  (949752813887)', function() {
14
        assert.deepEqual(byteData.toBytes([949752813887], 40, {"base": 16}),
15
            ["3f", "d9", "ad", "21", "dd"]);
16
    });  
17
    it('should turn 1 signed 40-bit int to 5 bytes (hex) (max range)', function() {
18
        assert.deepEqual(byteData.toBytes([-549755813888], 40, {"base": 16}),
19
            ["00","00","00","00","80"]);
20
    });
21
    it('should turn 1 unsigned 40-bit int to 5 bytes (hex) (max range)', function() {
22
        assert.deepEqual(byteData.toBytes([1099511627775], 40, {"base": 16}),
23
            ["ff","ff","ff","ff","ff"]);
24
    });
25
    it('should turn 1 unsigned 40-bit int to 5 bytes (max range)', function() {
26
        assert.deepEqual(byteData.toBytes([1099511627775], 40, {"base": 10}),
27
            [255,255,255,255,255]);
28
    });
29
});
30